﻿using System.IO;
using ICSharpCode.SharpZipLib.Core;

namespace PhiStore.Experiments.Compression
{
    class BasicCopy
    {
        public static Stream BasicStreamCopy(byte[] input, int bufferSize)
        {
            MemoryStream output = new MemoryStream();

            for (int i = 0; i < input.Length; i += bufferSize)
            {
                int length = (int)(i + bufferSize > input.Length ? input.Length - i : bufferSize);

                output.Write(input, i, length);
            }

            return output;
        }

        public static Stream StreamToStreamCopy(Stream input, int bufferSize)
        {
            MemoryStream output = new MemoryStream();
            input.Position = 0;

            byte[] buffer = new byte[bufferSize];
            StreamUtils.Copy(input, output, buffer);

            return output;
        }

    }
}
